﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL;

namespace WeChat.UserInfo
{
    public partial class SYSCount : System.Web.UI.Page
    {
        GetUserInfoBLL gb = new GetUserInfoBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string openid = Request.QueryString["openid"];
                //检测是否给当前页面传递了相关参数
                if (string.IsNullOrEmpty(openid))
                {
                    Response.Write("<span style='color:#FF0000;font-size:20px'>页面传参出错,请返回重试</span>");
                    Div1.Visible = false;
                }
                else
                {
                    DataTable dt = gb.getUserInfo(openid).Tables[0];
                    if (dt.Rows[0]["ryxm"].ToString() != "管理卡" || dt.Rows[0]["rfkh"].ToString() != "000001")
                    {
                        Response.Write("<span style='color:#FF0000;font-size:20px'>对不起，您无权浏览本页！</span>");
                        Div1.Visible = false;
                    }
                }
            }
        }

        //days事件，查询记录
        protected void days(object sender, EventArgs e)
        {
            string startTime = Request.Form["time1"];
            string endTime = Request.Form["time2"];
            if (startTime != "" && endTime != "")
            {
                startTime = DateTime.Parse(startTime).ToString("yyyy-MM-dd HH:mm:ss");
                endTime = DateTime.Parse(endTime).ToString("yyyy-MM-dd HH:mm:ss");
                searchtime.InnerText = startTime + " 至 " + endTime;
            }
            else
            {
                searchtime.InnerText = "";
            }
            DataTable dt = gb.getjeCount(startTime, endTime);
            xf1.Text = dt.Rows[0]["正常消费"].ToString() + "元";
            xf2.Text = dt.Rows[0]["餐费补扣"].ToString() + "元";
            xf3.Text = dt.Rows[0]["因错退还"].ToString() + "元";
            zk1.Text = dt.Rows[0]["现金交费"].ToString() + "元";
            zk2.Text = dt.Rows[0]["微信充值"].ToString() + "元";
            zk3.Text = dt.Rows[0]["单位补贴"].ToString() + "元";
            zk4.Text = dt.Rows[0]["换卡交费"].ToString() + "元";
            zk5.Text = dt.Rows[0]["开户押金"].ToString() + "元";
            zk6.Text = dt.Rows[0]["现金赠送"].ToString() + "元";
            zk7.Text = dt.Rows[0]["单位补贴"].ToString() + "元";
            zk8.Text = dt.Rows[0]["补贴充值"].ToString() + "元";
            zk9.Text = dt.Rows[0]["加款机"].ToString() + "元";
            zk10.Text = dt.Rows[0]["充值机"].ToString() + "元";
            zk11.Text = dt.Rows[0]["补贴机"].ToString() + "元";
            jk1.Text = dt.Rows[0]["补贴扣除"].ToString() + "元";
            jk2.Text = dt.Rows[0]["现金提取"].ToString() + "元";
            jk3.Text = dt.Rows[0]["退还押金"].ToString() + "元";
            jk4.Text = dt.Rows[0]["退还余额"].ToString() + "元";
            jk5.Text = dt.Rows[0]["退款机"].ToString() + "元";
            jk.Text = dt.Rows[0]["减款"].ToString() + "元";
            zk.Text = dt.Rows[0]["增款"].ToString() + "元";
            xf.Text = dt.Rows[0]["实际消费"].ToString() + "元";
            sr.Text = dt.Rows[0]["实际收入"].ToString() + "元";
        }
    }
}
